package cluedo;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Vector;

import javax.swing.ImageIcon;

/** Carta arma*/
public class Weapon extends Card {
	
	
	private static final long serialVersionUID = 5516362778554409205L;

	/**
	 * I possibili nomi delle armi associati ai path
	 */
	private final static HashMap<String,String> weapons = new HashMap<String,String>();
	static {
		weapons.put("rope", "/img/rope.jpg");
		weapons.put("leadPipe", "/img/leadpipe.jpg");
		weapons.put("knife", "/img/knife.jpg");
		weapons.put("wrench", "/img/wrench.jpg");
		weapons.put("candlestick", "/img/candlestick.jpg");
		weapons.put("revolver", "/img/revolver.jpg");
    }
	
	/**
	 * Costruttore carta arma
	 * @param name il nome dell'arma
	 */
	public Weapon(String name){
		
		if(weapons.containsKey(name)){
			this.name=name;
			setImage();
		}
		else
        	System.err.println("Weapon: Il nome dell'arma non e' valido");
		
	}		
	
	@Override
	protected void setImage(){
		
		cardImage = new ImageIcon(Weapon.class.getResource(weapons.get(this.name))); 
	}

	/**
	 * Restituisce una lista di tutte le carte arma
	 * @return vedi descrizione
	 */
	public static List<Weapon> allWeapons() {
		
		List<Weapon> list= new Vector<Weapon>(weapons.size());
		
		for(Map.Entry<String, String> entry : weapons.entrySet()){
			list.add(new Weapon(entry.getKey()));
		}
		
		return list;
	}
	
}
